<?php

namespace Application\controller;

use Cola\Controller;

class OrderController extends Controller
{
    public function create()
    {
        /* @var \Application\model\BaseOrderModel $m */
        $m = $this->model('Order');
        $msg = $m->initPayCallBack();
        if ($msg) $this->error($msg);
        $config = $m->checkProduct();
        if (!$config) $this->error('shopId invalid');
        if(!$m->checkOpenPay()){
            $this->error('Payment has been closed');
        }
        $orderInfo = $m->saveOrder($config);
        if (!$orderInfo) $this->error('insert order failed');
        $data = $m->getRetunData($config);
        $m->successLog();
        $this->success($data);
    }


}